package com.showsu.editor.enums;

import com.showsu.editor.utils.Constant;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @Author: jph
 * @Description: xhs作品是否限流枚举类
 * @Date: Created in 7:47 下午 2024/6/27
 * @Modified By:
 */
@Getter
@AllArgsConstructor
public enum XhsAwemeIsLimitedEnum {

    Normal(0, "正常"),
    Limited(1, "限流"),
    Delete(2, "作品无法正常展示"),
    NoNotesFound(3, "没找到笔记"),
    NoFields(4, "接口无限流字段"),
    Fail(5, "接口异常"),
    InvalidLink(6, "无效链接"),
    ;

    /**
     * 编码
     */
    final int code;

    /**
     * 描述
     */
    final String msg;

    public static XhsAwemeIsLimitedEnum getByCode(int code) {
        for (XhsAwemeIsLimitedEnum iEnum : XhsAwemeIsLimitedEnum.values()) {
            if (iEnum.getCode() == code)  {
                return iEnum;
            }
        }
        return XhsAwemeIsLimitedEnum.Fail;
    }

    public static String getIsLimitedStr(XhsAwemeIsLimitedEnum isLimitedEnum) {;
        switch (isLimitedEnum){
            case Normal :
            case Limited:
                return isLimitedEnum.getMsg();
            default:
                return Constant.analyzeHit7;
        }
    }
}
